/**
 * @file hdl_led.c
 * @author your name (you@domain.com)
 * @brief
 * @version 0.1
 * @date 2025-01-08
 *
 * @copyright Copyright (c) 2025
 *
 */
/* includes ----------------------------------------------------------*/
#include "hdl_led.h"
/* typedef -----------------------------------------------------------*/
/* define ------------------------------------------------------------*/
/* variables ---------------------------------------------------------*/
/* function prototypes -----------------------------------------------*/

/**
 * @brief 初始化基本的LED灯
 * @note 使用的引脚: PC10 PC11 PC12
 */
void vhdl_led_init(cfg_led_pin_t pin_sturct[], uint8_t len)
{

    GPIO_InitTypeDef xhal_led_gpio_struct;

    for (size_t i = 0; i < len; i++) {
        /* 时钟初始化 */
        pin_sturct[i].rcc_clk_cmd_t(pin_sturct[i].pin_clk, ENABLE);

        // 引脚模块默认初始化
        GPIO_StructInit(&xhal_led_gpio_struct);

        xhal_led_gpio_struct.GPIO_Mode = pin_sturct[i].pin_mode;
        xhal_led_gpio_struct.GPIO_Pin  = pin_sturct[i].pin_num;
        GPIO_Init(pin_sturct[i].pin_port, &xhal_led_gpio_struct);

        GPIO_SetBits(pin_sturct[i].pin_port, pin_sturct[i].pin_num);
    }
}

/**
 * @brief 打开单个led
 *
 * @param led_port
 * @param led_pin
 */
void vhdl_led_on(GPIO_TypeDef* led_port, uint16_t led_pin)
{
    GPIO_ResetBits(led_port, led_pin);
}

/**
 * @brief 关闭单个led
 *
 * @param led_port
 * @param led_pin
 */
void vhdl_led_off(GPIO_TypeDef* led_port, uint16_t led_pin)
{
    GPIO_SetBits(led_port, led_pin);
}
